package com.lry.rpc;

import com.lry.BrokerController;
import com.lry.message.AckMessage;
import com.lry.message.Message;
import com.lry.message.MessageExt;
import com.lry.message.PullMessage;
import com.lry.producer.SendResult;
import com.lry.topic.TopicPublishInfo;

import java.util.List;

public class MqRpcServiceImpl implements MqRpcService{

    BrokerController brokerController;

    public MqRpcServiceImpl(BrokerController brokerController){
        this.brokerController = brokerController;
    }
    @Override
    public SendResult sendMsg(Message msg) {
        return brokerController.produce(msg);
    }

    @Override
    public SendResult sendMsg(Message msg, int queueId) {
        return brokerController.produce(msg,queueId);
    }

    @Override
    public List<MessageExt> pullMessage(PullMessage pullMessage) {
        return brokerController.consume(pullMessage);
    }

    @Override
    public void ack(AckMessage ackMessage) {
        brokerController.ack(ackMessage);
    }

    @Override
    public TopicPublishInfo tryToFindTopicPublishInfo(String topic) {
        return brokerController.queryTopic(topic);
    }


}
